package vip.bblog.oauth2.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import vip.bblog.oauth2.common.LoginUser;


/**
 * 实现UserDetailsService，到数据库查找信息
 *
 * @author 偶尔有点困
 * @date 2018年5月21日
 */
@Service
public class UserDetailServiceImpl implements UserDetailsService {

	@Autowired
	private PasswordEncoder passwordEncoder;

	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		LoginUser loginUser = new LoginUser();
		loginUser.setUsername("admin");
		loginUser.setPassword(passwordEncoder.encode("admin"));
		return loginUser;
	}

}
